package cn.tedu.charging.user.dao.repository.impl;

import cn.tedu.charging.user.dao.mapper.UserMapper;
import cn.tedu.charging.user.dao.repository.UserRepository;
import cn.tedu.charging.user.pojo.UserPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class UserRepositoryImpl implements UserRepository {

    @Autowired
    private UserMapper userMapper;

    @Override
    public UserPO getUserInfoByOpenId(String openId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("wx_open_id",openId);
        return userMapper.selectOne(queryWrapper);
    }

    @Override
    public Integer save(UserPO userPO) {
        userMapper.insert(userPO);
        //保存成功后 plus 自动会填充id
        return userPO.getId();
    }
}
